#include "shaders/Conductor.hpp"
#include "samplers/SamplerInstance.hpp"

#include "glm/gtc/matrix_transform.hpp"

#include "Onb.hpp"

namespace PhotonMapping
{
    Conductor::Conductor(Material& material, vector<Texture>& textures)
        : Shader(material, textures)
    {
        auto _reflect = material.getProperty<Property::Wrapper::RGBType>("reflect");
        if (_reflect) reflect = (*_reflect).value;
        else reflect = { 1, 1, 1 };
    }
    Scattered Conductor::shade(const Ray& ray, const Vec3& hitPoint, const Vec3& normal, bool photonStage) const {
        Vec3 origin = hitPoint;

        Vec3 direction = ray.direction - 2.f * glm::dot(normal, ray.direction) * normal;

        auto attenuation = reflect / PI;

        float pdf = 1 / (2 * PI);

        return {
            Ray{origin, direction},
            attenuation,
            Vec3{0},
            pdf
        };
    }
}